package com.lyt.controller;

import com.alibaba.fastjson.JSON;
import com.lyt.bean.*;
import com.lyt.dao.PaperDao;
import com.lyt.dao.QuestionDao;
import com.lyt.service.QuestionService;
import com.lyt.service.TestService;
import com.lyt.util.BeanUtil;
import com.lyt.vo.ItemVo;
import com.lyt.vo.PaperVo;
import com.lyt.vo.QuestionVo;
import com.lyt.vo.QuestionsVo;
import org.apache.ibatis.annotations.Param;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: lyt
 * @Date: 2023/05/21/17:55
 * @Description:
 */
@RestController
@CrossOrigin
public class TestController {

    @Autowired
    TestService testService;

    @RequestMapping("/testExam/get")//根据学生的班级 、查询的课程 获取 试卷
    public List<PaperVo> getPaperById(@Param("courseId") Integer courseId,@Param("grade") int grade){
        System.out.println("courseId是"+courseId);

    return testService.getPaperById(courseId,grade);
    }

    @RequestMapping("/publish/paper")//根据学生id获取 试卷
    public Integer publishPaper(@RequestBody PublishPaper publishPaper){

        System.out.println("接收到的参数是"+publishPaper);

        return testService.insertPublishPaper(publishPaper);
    }

    @RequestMapping("/testTime/get")//根据学生id获取 试卷
    public int publishPaper(int paperId){

        return testService.getTestTime(paperId);
    }
}
